package toolsUseCourse.javaFoundation.datatypeoperations.stringoperation;


import com.oneheart.xp.framework.util.UtilPub;

public final class StringOperation {

    //    删除字符串中的某指定单词(不区分大小写)
    public static String deleteWord(String s){
        String regex = "[T,t][H,h][E,e]";
        return s.replaceAll(regex,"");
    }




    //    删除字符串中的第一次出现的某指定单词(不区分大小写)
    public static String deleteFirstWord(String s){
        String regex = "[T,t][H,h][E,e]";
        return s.replaceFirst(regex,"");
    }


    /*
       // 空字符串得出来的还是空的
    * String parentIdList = "";
      String regex = "-";
      parentIdList = parentIdList.replaceFirst(regex,"");
      System.out.println(parentIdList + "test");
      *
    * */



    public static void main(String[] args) {

        String s1 = "Hello The World! thE  THE THe";
        //以该字符串为例，删除字符串中所有的 "The" 单词，不区分大小写
        System.out.println(deleteWord(s1));

        String s2 = "Hello The World! thE  THE THe";
        System.out.println(deleteFirstWord(s2));



        //
/*        String parentId1 = "";
        String parentId2 = "-1298504848664166400";
        String parentId3 = "-1298504848664166400-1298505509577424896";

        String[] parentIdList1 = parentId1.split("-");
        parentIdList1.toString();
        String[] parentIdList2 = parentId2.split("-");
        parentIdList2.toString();
        String[] parentIdList3 = parentId3.split("-");
        parentIdList3.toString();*/

    }

    public static String getFirstId(String ids) {
        String firstId = "";
        if (UtilPub.isNotEmptyId(ids)) {
            ids = ids.substring(0,ids.length()-1);
        }
        if (UtilPub.isNotEmptyId(ids)) {
            for (String bd : ids.split(",")) {
                firstId += ("," + bd + "");
            }
        }
        if (UtilPub.isNotEmptyId(firstId)) {
            firstId = firstId.substring(1);
        }
        String[] idsArray = ids.split(",");
        firstId = ids.substring(0,1);

        return firstId;
    }



}
